<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib uri="/WEB-INF/html.tld" prefix="html" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>

<c:url var="financialCalculator" value="/admin/financial/calculator" />
		<div class="content-backgroud">

<form id="financialProduct" method="POST" >
	<html:table attributes="class='inputTable'">
	<html:tr>
    <html:td attributes="colspan='4'"><div class="formHeader">Financial Product Calculator</div></html:td>
  </html:tr>
	  <html:tr>
	    
	    <html:td><label>Financed Amount</label></html:td>
	    <html:td><label>Term</label></html:td>
	    <html:td><label>Amortization</label></html:td>
	    <html:td><label>Rate</label></html:td>
	   
	  </html:tr>
	  <html:tr>
	   
	    <html:td append="div"><input type="number" name="financedAmount" class='required'/></html:td>
	    <html:td append="div">
	    	<select name="term" class='required'><html:lov attributes="name='rateband.type'" code="TERM">Term List</html:lov></select>
	    </html:td>
	    <html:td append="div">
	    	<select name="amortization" class='required'><html:lov attributes="name='rateband.type'" code="TERM">Term List</html:lov></select>
	    </html:td>
	      <html:td append="div">
	    	<input type="number" name="rate" class='required' />
	    </html:td>
	  </html:tr>
	</html:table>
</form>
<div id="rateBandView"><button type="button" id="btnCalculate">Calculate</button></div>
</div>

<script>
$(function () {
	
	$("#btnCalculate").on("click",function(){
		
		jQuery.ajaxSettings.traditional = true;
	
		var formData = $("#financialProduct").serializeObject();
		//formData.rateCards=assignedRate;
	
		var params={url:"admin/calculator/calculate",success:onSuccess,data:formData,type:"POST",dataType:"json"};
		doAjax(params);
		return false;
	});
	
    function onSuccess(result)
    {
    	 console.log(result);
    	
    }
 });
</script>
